//
//  SignUpSuccessViewController.m
//  YXFinance
//
//  Created by uplooking on 2018/10/31.
//  Copyright © 2018年 CRLong. All rights reserved.
//

#import "SignUpSuccessViewController.h"

@interface SignUpSuccessViewController ()
{
    UIScrollView * scrollView;
    ConfigSignupFormTipsModel * configSignupTipsModel;
}

@end

@implementation SignUpSuccessViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"恭喜您！报名成功";
//    self.title = @"立即报名";
    [self setBackLeftBarButtonItemAction:@selector(backAction:)];
    [self initView];
    
//    [self startSKV];
//    [self getCongifTipsData];
}

- (void)backAction:(UIButton *)sender{
    
    [self.navigationController popViewControllerAnimated:YES];
    
}

- (void)initNewView{
    
    SignupInfoModel * model = [UserCenterHelper shareInstance].userModel.signup_info;
    
    scrollView=[[UIScrollView alloc]init];
    [self.view addSubview:scrollView];
    [scrollView setShowsHorizontalScrollIndicator:NO];
    [scrollView setShowsVerticalScrollIndicator:NO];
    [scrollView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.view);
    }];
    
    
    UIView *vContainer = [UIView new];
    [scrollView addSubview:vContainer];
    [vContainer mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(scrollView);
        make.width.equalTo(scrollView);
    }];

    
    UIView * topView = [[UIView alloc]init];
    [vContainer addSubview:topView];
    [topView setBackgroundColor:[UIColor whiteColor]];
    [topView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.equalTo(vContainer);
    }];
    
    
    UILabel * labelTitle = [[UILabel alloc]init];
    [labelTitle setText:@"手机号码"];
    [labelTitle setTextColor:HexRGBA(0x000000, 1)];
    [labelTitle setFont:[UIFont systemFontOfSize:16 * kAutoScanleX]];
    [labelTitle setTextAlignment:NSTextAlignmentLeft];
    [topView addSubview:labelTitle];
    [labelTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.equalTo(topView).offset(15 * kAutoScanleX);
    }];
    
    UILabel * labelPhone = [[UILabel alloc]init];
    [labelPhone setText:model.mobile];
    [labelPhone setTextColor:HexRGBA(0xa7a7a7, 1)];
    [labelPhone setFont:[UIFont systemFontOfSize:14 * kAutoScanleX]];
    [labelPhone setTextAlignment:NSTextAlignmentLeft];
    [topView addSubview:labelPhone];
    [labelPhone mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(labelTitle.mas_bottom).offset(10 * kAutoScanleX);
        make.left.equalTo(topView).offset(15 * kAutoScanleX);
    }];
    
    [topView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(labelPhone.mas_bottom).offset(15 * kAutoScanleX);
    }];
    
    
    
    UIView * midView = [[UIView alloc]init];
    [vContainer addSubview:midView];
    [midView setBackgroundColor:[UIColor whiteColor]];
    [midView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(topView.mas_bottom).offset(10 * kAutoScanleX);
        make.left.right.equalTo(vContainer);
    }];
    
    
     labelTitle = [[UILabel alloc]init];
    [labelTitle setTextColor:HexRGBA(0x000000, 1)];
    [labelTitle setText:@"国融证券股票账户"];
    [labelTitle setFont:[UIFont systemFontOfSize:16 * kAutoScanleX]];
    [labelTitle setTextAlignment:NSTextAlignmentLeft];
    [midView addSubview:labelTitle];
    [labelTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(midView).offset(15 * kAutoScanleX);
        make.top.equalTo(midView).offset(15 * kAutoScanleX);
    }];
    
    
    UITextField * accountTextField =[[UITextField alloc]init];
    [accountTextField setText:model.account];
    [accountTextField setUserInteractionEnabled:NO];
    [midView addSubview:accountTextField];
    [accountTextField setTextColor:HexRGBA(0xa7a7a7, 1)];
    [accountTextField setKeyboardType:UIKeyboardTypeEmailAddress];
    [accountTextField setReturnKeyType:UIReturnKeyDone];
    [accountTextField setFont:[UIFont systemFontOfSize:14 * kAutoScanleX]];
    [accountTextField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(labelTitle.mas_bottom).offset(10 * kAutoScanleX);
        make.left.equalTo(midView).offset(15 * kAutoScanleX);
        make.right.equalTo(midView).offset(-15 * kAutoScanleX);
        make.height.mas_equalTo(30 * kAutoScanleX);
    }];
    
    
    UIView *line = [[UIView alloc]init];
    [line setBackgroundColor:HexRGBA(0xcfd4db, 1)];
    [midView addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.left.right.equalTo(accountTextField);
        make.height.mas_equalTo(0.5);
    }];
    
    
    UILabel * labelTips1 = [[UILabel alloc]init];
    [labelTips1 setTextColor:HexRGBA(0x000000, 1)];
    [labelTips1 setText:configSignupTipsModel.atips0];
    [labelTips1 setAdjustsFontSizeToFitWidth:YES];
    [labelTips1 setFont:[UIFont systemFontOfSize:14 * kAutoScanleX]];
    [labelTips1 setTextAlignment:NSTextAlignmentLeft];
    [midView addSubview:labelTips1];
    [labelTips1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(midView).offset(15 * kAutoScanleX);
        make.top.equalTo(line.mas_bottom).offset(10 * kAutoScanleX);
    }];
    
    
    UIButton * button = [[UIButton alloc]init];
    [button addTarget:self action:@selector(backCustomerAction:) forControlEvents:UIControlEventTouchUpInside];
    [button setTitle:configSignupTipsModel.aLinkText forState:UIControlStateNormal];
    [button.titleLabel setFont:[UIFont systemFontOfSize:14 * kAutoScanleX]];
    [button setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
    [midView addSubview:button];
    [button mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(labelTips1);
        make.left.equalTo(labelTips1.mas_right);
        make.height.mas_equalTo(20 * kAutoScanleX);
    }];
    
    
    [midView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(labelTips1.mas_bottom).offset(20 * kAutoScanleX);
    }];
    
    
    UIView * teatcherView = [[UIView alloc]init];
    [teatcherView setBackgroundColor:[UIColor whiteColor]];
    [vContainer addSubview:teatcherView];
    [teatcherView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(midView.mas_bottom).offset(10 * kAutoScanleX);
        make.left.right.equalTo(midView);
        make.height.mas_equalTo(55 * kAutoScanleX);
    }];
    
    UILabel * label = [[UILabel alloc]init];
    [label setTextColor:HexRGBA(0x585858, 1)];
    [label setText:@"荣誉导师"];
    [label setFont:[UIFont systemFontOfSize:14 * kAutoScanleX]];
    [label setTextAlignment:NSTextAlignmentRight];
    [teatcherView addSubview:label];
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(teatcherView);
        make.left.equalTo(teatcherView).offset(15 * kAutoScanleX);
        make.width.mas_equalTo(60 * kAutoScanleX);
        make.height.mas_equalTo(25 * kAutoScanleX);
    }];
    
    
    UITextField * teacherTextField = [[UITextField alloc]init];
    [teacherTextField setText:model.teacher.teacher_name];
    [teacherTextField setUserInteractionEnabled:NO];
    [teatcherView addSubview:teacherTextField];
    [teacherTextField setTextColor:HexRGBA(0x000000, 1)];
    [teacherTextField setReturnKeyType:UIReturnKeyDone];
    [teacherTextField setFont:[UIFont systemFontOfSize:14 * kAutoScanleX]];
    [teacherTextField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(teatcherView);
        make.left.equalTo(label.mas_right).offset(30 * kAutoScanleX);
        make.right.equalTo(teatcherView).offset(-15 * kAutoScanleX);
        make.height.mas_equalTo(30 * kAutoScanleX);
    }];
    
    UIButton * registerBtn = [[UIButton alloc]init];
    [registerBtn setBackgroundColor:HexRGBA(0xb99c6d, 1)];
    [registerBtn addTarget:self action:@selector(registerBtnAction:) forControlEvents:UIControlEventTouchUpInside];
    [registerBtn.layer setMasksToBounds:YES];
    [registerBtn.layer setCornerRadius:8.0 * kAutoScanleX];
    [registerBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [registerBtn setTitle:@"下一步" forState:UIControlStateNormal];
    [registerBtn.titleLabel setFont:[UIFont systemFontOfSize:16 * kAutoScanleX]];
    [vContainer addSubview:registerBtn];
    [registerBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(teatcherView.mas_bottom).offset(20 * kAutoScanleX);
        make.height.mas_equalTo(45 * kAutoScanleX);
        make.centerX.equalTo(vContainer);
        make.width.mas_equalTo(576/2.0 * kAutoScanleX);
    }];
    
    [vContainer mas_updateConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(registerBtn).offset(30 * kAutoScanleX);
    }];
}


- (void)initView{
    
    UIImageView * imageView = [[UIImageView alloc]init];
    [self.view addSubview:imageView];
    [imageView setImage:[UIImage imageNamed:@"img_baoming"]];
    [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view);
        make.top.equalTo(self.view).offset(50  * kAutoScanleX);
        make.size.mas_equalTo(CGSizeMake(230 * kAutoScanleX, 177.5 * kAutoScanleX));
    }];
    
    
    UILabel * labelTitle = [[UILabel alloc]init];
    [labelTitle setText:@"报名成功"];
    [labelTitle setTextColor:HexRGBA(0xb18132, 1)];
    [labelTitle setFont:[UIFont boldSystemFontOfSize:24 * kAutoScanleX]];
    [labelTitle setTextAlignment:NSTextAlignmentLeft];
    [self.view addSubview:labelTitle];
    [labelTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(imageView);
        make.top.equalTo(imageView.mas_bottom).offset(30 * kAutoScanleX);
    }];
    
    
    
    UILabel * labelContent = [[UILabel alloc]init];
    [labelContent setText:@"您当前报名的手机号为"];
    [labelContent setTextColor:HexRGBA(0x0c1725, 1)];
    [labelContent setFont:[UIFont systemFontOfSize:15 * kAutoScanleX]];
    [labelContent setTextAlignment:NSTextAlignmentLeft];
    [self.view addSubview:labelContent];
    [labelContent mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(labelTitle);
        make.top.equalTo(labelTitle.mas_bottom).offset(20 * kAutoScanleX);
    }];
    
    
    UserModel * model = [UserCenterHelper shareInstance].userModel;
    
    UILabel * labelPhone = [[UILabel alloc]init];
    [labelPhone setText:[NSString stringWithFormat:@"%@",model.signup]];
    [labelPhone setTextColor:HexRGBA(0xc61d19, 1)];
    [labelPhone setFont:[UIFont systemFontOfSize:15 * kAutoScanleX]];
    [labelPhone setTextAlignment:NSTextAlignmentLeft];
    [self.view addSubview:labelPhone];
    [labelPhone mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(labelContent);
        make.top.equalTo(labelContent.mas_bottom).offset(10 * kAutoScanleX);
    }];
    
    UIButton * registerBtn = [[UIButton alloc]init];
    [registerBtn setBackgroundColor:HexRGBA(0xb99c6d, 1)];
    [registerBtn addTarget:self action:@selector(registerBtnAction:) forControlEvents:UIControlEventTouchUpInside];
    [registerBtn.layer setMasksToBounds:YES];
    [registerBtn.layer setCornerRadius:8.0 * kAutoScanleX];
    [registerBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [registerBtn setTitle:@"下一步" forState:UIControlStateNormal];
    [registerBtn.titleLabel setFont:[UIFont systemFontOfSize:16 * kAutoScanleX]];
    [self.view addSubview:registerBtn];
    [registerBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(labelPhone.mas_bottom).offset(50 * kAutoScanleX);
        make.height.mas_equalTo(45 * kAutoScanleX);
        make.centerX.equalTo(self.view);
        make.width.mas_equalTo(576/2.0 * kAutoScanleX);
    }];
    
    
}

#pragma mark -- 下一步
- (void)registerBtnAction:(UIButton *)sender{
    
    NSString * url = [UserCenterHelper shareInstance].configureModel.html5_jump_url;
    
    MyWebViewController * vc = [[MyWebViewController alloc]init];
    vc.url = url;
    [self.navigationController pushViewController:vc animated:YES];
    
}

#pragma mark -- 客服热线
- (void)backCustomerAction:(UIButton *)sender{
    
    NSMutableString * str=[[NSMutableString alloc] initWithFormat:@"telprompt://%@",configSignupTipsModel.aLinkValue];
    
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:str] options:@{@"":@""} completionHandler:nil];

}

#pragma mark -- 获取数据
- (void)getCongifTipsData{
    
    WS(weakSelf);
    
    [HttpRequestHelper requestApiConfigutrSignupFormTipsBlock:^(NSString *msg, ConfigSignupFormTipsModel *indexModel) {
        
        [weakSelf hideHud];
        [weakSelf stopSKV];
        
        if (REQUEST_SUCCESS) {
            
            configSignupTipsModel = indexModel;
            [weakSelf initNewView];
        }
    }];
    
}

@end
